﻿using Newtonsoft.Json;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

namespace Domain.Models
{
    [DisplayName("菜单")]
    public class Navigation : BaseEntity
    {
        [DisplayName("编号")]
        public int Id { get; set; }

        [DisplayName("父编号")]
        [DefaultValue(0)]
        public int? ParentId { get; set; }

        [DisplayName("名称")]
        [StringLength(400)]
        [NotNull]
        public string Name { get; set; }

        [DisplayName("顺序级别")]
        [DefaultValue(0)]
        public int SerialNum { get; set; }

        [DisplayName("地址")]
        [StringLength(200)]
        [NotNull]
        public string Url { get; set; }

        [DisplayName("图标")]
        [StringLength(100)]
        public string Icon { get; set; }

        [DisplayName("父菜单")]
        [JsonIgnore]
        public virtual Navigation Parent { get; set; }

        [DisplayName("子菜单")]
        public virtual ICollection<Navigation> Children { get; set; } = new List<Navigation>();

        [JsonIgnore]
        [DisplayName("菜单权限")]
        public virtual ICollection<PermissionNavigation> PermissionNavigations { get; set; } = new List<PermissionNavigation>();
    }
}
